home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / ADSP.h next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  11.4 KB  |  306 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        ADSP.h
  3.  
  4.      Contains:    AppleTalk Data Stream Protocol (ADSP) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1986-1999, 1995-1997, 1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __ADSP__
  18. #define __ADSP__
  19.  
  20. #ifndef __MACERRORS__
  21.     #include <MacErrors.h>
  22. #endif
  23.  
  24. #ifndef __APPLETALK__
  25.     #include <AppleTalk.h>
  26. #endif
  27.  
  28.  
  29.  
  30.  
  31. #if PRAGMA_ONCE
  32. #pragma once
  33. #endif
  34.  
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38.  
  39. #if PRAGMA_IMPORT
  40. #pragma import on
  41. #endif
  42.  
  43. #if PRAGMA_STRUCT_ALIGN
  44.     #pragma options align=mac68k
  45. #elif PRAGMA_STRUCT_PACKPUSH
  46.     #pragma pack(push, 2)
  47. #elif PRAGMA_STRUCT_PACK
  48.     #pragma pack(2)
  49. #endif
  50.  
  51. /*driver control csCodes*/
  52. enum {
  53.     dspInit                        = 255,                            /* create a new connection end */
  54.     dspRemove                    = 254,                            /* remove a connection end */
  55.     dspOpen                        = 253,                            /* open a connection */
  56.     dspClose                    = 252,                            /* close a connection */
  57.     dspCLInit                    = 251,                            /* create a connection listener */
  58.     dspCLRemove                    = 250,                            /* remove a connection listener */
  59.     dspCLListen                    = 249,                            /* post a listener request */
  60.     dspCLDeny                    = 248,                            /* deny an open connection request */
  61.     dspStatus                    = 247,                            /* get status of connection end */
  62.     dspRead                        = 246,                            /* read data from the connection */
  63.     dspWrite                    = 245,                            /* write data on the connection */
  64.     dspAttention                = 244,                            /* send an attention message */
  65.     dspOptions                    = 243,                            /* set connection end options */
  66.     dspReset                    = 242,                            /* forward reset the connection */
  67.     dspNewCID                    = 241                            /* generate a cid for a connection end */
  68. };
  69.  
  70. enum {
  71.                                                                 /* connection opening modes */
  72.     ocRequest                    = 1,                            /* request a connection with remote */
  73.     ocPassive                    = 2,                            /* wait for a connection request from remote */
  74.     ocAccept                    = 3,                            /* accept request as delivered by listener */
  75.     ocEstablish                    = 4                                /* consider connection to be open */
  76. };
  77.  
  78. enum {
  79.                                                                 /* connection end states */
  80.     sListening                    = 1,                            /* for connection listeners */
  81.     sPassive                    = 2,                            /* waiting for a connection request from remote */
  82.     sOpening                    = 3,                            /* requesting a connection with remote */
  83.     sOpen                        = 4,                            /* connection is open */
  84.     sClosing                    = 5,                            /* connection is being torn down */
  85.     sClosed                        = 6                                /* connection end state is closed */
  86. };
  87.  
  88. enum {
  89.                                                                 /* client event flags */
  90.     eClosed                        = 0x80,                            /* received connection closed advice */
  91.     eTearDown                    = 0x40,                            /* connection closed due to broken connection */
  92.     eAttention                    = 0x20,                            /* received attention message */
  93.     eFwdReset                    = 0x10                            /* received forward reset advice */
  94. };
  95.  
  96. enum {
  97.                                                                 /* miscellaneous constants */
  98.     attnBufSize                    = 570,                            /* size of client attention buffer */
  99.     minDSPQueueSize                = 100                            /* Minimum size of receive or send Queue */
  100. };
  101.  
  102. /* connection control block */
  103. typedef struct TRCCB                     TRCCB;
  104. typedef TRCCB *                            TPCCB;
  105.  
  106. struct TRCCB {
  107.     TPCCB                             ccbLink;                    /* link to next ccb */
  108.     UInt16                             refNum;                        /* user reference number */
  109.     UInt16                             state;                        /* state of the connection end */
  110.     UInt8                             userFlags;                    /* flags for unsolicited connection events */
  111.     UInt8                             localSocket;                /* socket number of this connection end */
  112.     AddrBlock                         remoteAddress;                /* internet address of remote end */
  113.     UInt16                             attnCode;                    /* attention code received */
  114.     UInt16                             attnSize;                    /* size of received attention data */
  115.     void *                            attnPtr;                    /* ptr to received attention data */
  116.     UInt8                             reserved[220];                /* for adsp internal use */
  117. };
  118.  
  119. typedef CALLBACK_API( void , ADSPConnectionEventProcPtr )(TPCCB sourceCCB);
  120. /*
  121.     WARNING: ADSPConnectionEventProcPtr uses register based parameters under classic 68k
  122.              and cannot be written in a high-level language without 
  123.              the help of mixed mode or assembly glue.
  124. */
  125. typedef struct DSPParamBlock             DSPParamBlock;
  126. typedef DSPParamBlock *                    DSPPBPtr;
  127. typedef CALLBACK_API( void , ADSPCompletionProcPtr )(DSPPBPtr thePBPtr);
  128. /*
  129.     WARNING: ADSPCompletionProcPtr uses register based parameters under classic 68k
  130.              and cannot be written in a high-level language without 
  131.              the help of mixed mode or assembly glue.
  132. */
  133. typedef REGISTER_UPP_TYPE(ADSPConnectionEventProcPtr)             ADSPConnectionEventUPP;
  134. typedef REGISTER_UPP_TYPE(ADSPCompletionProcPtr)                 ADSPCompletionUPP;
  135.  
  136. struct TRinitParams {
  137.     TPCCB                             ccbPtr;                        /* pointer to connection control block */
  138.     ADSPConnectionEventUPP             userRoutine;                /* client routine to call on event */
  139.     UInt16                             sendQSize;                    /* size of send queue (0..64K bytes) */
  140.     void *                            sendQueue;                    /* client passed send queue buffer */
  141.     UInt16                             recvQSize;                    /* size of receive queue (0..64K bytes) */
  142.     void *                            recvQueue;                    /* client passed receive queue buffer */
  143.     void *                            attnPtr;                    /* client passed receive attention buffer */
  144.     UInt8                             localSocket;                /* local socket number */
  145.     UInt8                             filler1;                    /* filler for proper byte alignment */
  146. };
  147. typedef struct TRinitParams                TRinitParams;
  148.  
  149. struct TRopenParams {
  150.     UInt16                             localCID;                    /* local connection id */
  151.     UInt16                             remoteCID;                    /* remote connection id */
  152.     AddrBlock                         remoteAddress;                /* address of remote end */
  153.     AddrBlock                         filterAddress;                /* address filter */
  154.     UInt32                             sendSeq;                    /* local send sequence number */
  155.     UInt16                             sendWindow;                    /* send window size */
  156.     UInt32                             recvSeq;                    /* receive sequence number */
  157.     UInt32                             attnSendSeq;                /* attention send sequence number */
  158.     UInt32                             attnRecvSeq;                /* attention receive sequence number */
  159.     UInt8                             ocMode;                        /* open connection mode */
  160.     UInt8                             ocInterval;                    /* open connection request retry interval */
  161.     UInt8                             ocMaximum;                    /* open connection request retry maximum */
  162.     UInt8                             filler2;                    /* filler for proper byte alignment */
  163. };
  164. typedef struct TRopenParams                TRopenParams;
  165.  
  166. struct TRcloseParams {
  167.     UInt8                             abort;                        /* abort connection immediately if non-zero */
  168.     UInt8                             filler3;                    /* filler for proper byte alignment */
  169. };
  170. typedef struct TRcloseParams            TRcloseParams;
  171.  
  172. struct TRioParams {
  173.     UInt16                             reqCount;                    /* requested number of bytes */
  174.     UInt16                             actCount;                    /* actual number of bytes */
  175.     void *                            dataPtr;                    /* pointer to data buffer */
  176.     UInt8                             eom;                        /* indicates logical end of message */
  177.     UInt8                             flush;                        /* send data now */
  178. };
  179. typedef struct TRioParams                TRioParams;
  180.  
  181. struct TRattnParams {
  182.     UInt16                             attnCode;                    /* client attention code */
  183.     UInt16                             attnSize;                    /* size of attention data */
  184.     void *                            attnData;                    /* pointer to attention data */
  185.     UInt8                             attnInterval;                /* retransmit timer in 10-tick intervals */
  186.     UInt8                             filler4;                    /* filler for proper byte alignment */
  187. };
  188. typedef struct TRattnParams                TRattnParams;
  189.  
  190. struct TRstatusParams {
  191.     TPCCB                             statusCCB;                    /* pointer to ccb */
  192.     UInt16                             sendQPending;                /* pending bytes in send queue */
  193.     UInt16                             sendQFree;                    /* available buffer space in send queue */
  194.     UInt16                             recvQPending;                /* pending bytes in receive queue */
  195.     UInt16                             recvQFree;                    /* available buffer space in receive queue */
  196. };
  197. typedef struct TRstatusParams            TRstatusParams;
  198.  
  199. struct TRoptionParams {
  200.     UInt16                             sendBlocking;                /* quantum for data packets */
  201.     UInt8                             sendTimer;                    /* send timer in 10-tick intervals */
  202.     UInt8                             rtmtTimer;                    /* retransmit timer in 10-tick intervals */
  203.     UInt8                             badSeqMax;                    /* threshold for sending retransmit advice */
  204.     UInt8                             useCheckSum;                /* use ddp packet checksum */
  205. };
  206. typedef struct TRoptionParams            TRoptionParams;
  207.  
  208. struct TRnewcidParams {
  209.     UInt16                             newcid;                        /* new connection id returned */
  210. };
  211. typedef struct TRnewcidParams            TRnewcidParams;
  212.  
  213. struct DSPParamBlock {
  214.     QElem *                            qLink;
  215.     short                             qType;
  216.     short                             ioTrap;
  217.     Ptr                             ioCmdAddr;
  218.     ADSPCompletionUPP                 ioCompletion;
  219.     OSErr                             ioResult;
  220.     StringPtr                         ioNamePtr;
  221.     short                             ioVRefNum;
  222.     short                             ioCRefNum;                    /* adsp driver refNum */
  223.     short                             csCode;                        /* adsp driver control code */
  224.     long                             qStatus;                    /* adsp internal use */
  225.     short                             ccbRefNum;
  226.     union {
  227.         TRinitParams                     initParams;
  228.         TRopenParams                     openParams;
  229.         TRcloseParams                     closeParams;            /*dspClose, dspRemove*/
  230.         TRioParams                         ioParams;                /*dspRead, dspWrite*/
  231.         TRattnParams                     attnParams;                /*dspAttention*/
  232.         TRstatusParams                     statusParams;            /*dspStatus*/
  233.         TRoptionParams                     optionParams;            /*dspOptions*/
  234.         TRnewcidParams                     newCIDParams;            /*dspNewCID*/
  235.     }                                 u;
  236. };
  237.  
  238. #if OPAQUE_UPP_TYPES
  239.     EXTERN_API(ADSPConnectionEventUPP)
  240.     NewADSPConnectionEventUPP       (ADSPConnectionEventProcPtr userRoutine);
  241.  
  242.     EXTERN_API(ADSPCompletionUPP)
  243.     NewADSPCompletionUPP           (ADSPCompletionProcPtr    userRoutine);
  244.  
  245.     EXTERN_API(void)
  246.     DisposeADSPConnectionEventUPP    (ADSPConnectionEventUPP userUPP);
  247.  
  248.     EXTERN_API(void)
  249.     DisposeADSPCompletionUPP       (ADSPCompletionUPP        userUPP);
  250.  
  251.     EXTERN_API(void)
  252.     InvokeADSPConnectionEventUPP    (TPCCB                    sourceCCB,
  253.                                     ADSPConnectionEventUPP    userUPP);
  254.  
  255.     EXTERN_API(void)
  256.     InvokeADSPCompletionUPP           (DSPPBPtr                thePBPtr,
  257.                                     ADSPCompletionUPP        userUPP);
  258.  
  259. #else
  260.     enum { uppADSPConnectionEventProcInfo = 0x0000B802 };             /* register no_return_value Func(4_bytes:A1) */
  261.     enum { uppADSPCompletionProcInfo = 0x00009802 };                 /* register no_return_value Func(4_bytes:A0) */
  262.     #define NewADSPConnectionEventUPP(userRoutine)                     (ADSPConnectionEventUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPConnectionEventProcInfo, GetCurrentArchitecture())
  263.     #define NewADSPCompletionUPP(userRoutine)                         (ADSPCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPCompletionProcInfo, GetCurrentArchitecture())
  264.     #define DisposeADSPConnectionEventUPP(userUPP)                     DisposeRoutineDescriptor(userUPP)
  265.     #define DisposeADSPCompletionUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  266.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  267.     #pragma parameter InvokeADSPConnectionEventUPP(__A1, __A0)
  268.     void InvokeADSPConnectionEventUPP(TPCCB sourceCCB, ADSPConnectionEventUPP userUPP) = 0x4E90;
  269.     #else
  270.         #define InvokeADSPConnectionEventUPP(sourceCCB, userUPP)         CALL_ONE_PARAMETER_UPP((userUPP), uppADSPConnectionEventProcInfo, (sourceCCB))
  271.     #endif
  272.     #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  273.     #pragma parameter InvokeADSPCompletionUPP(__A0, __A1)
  274.     void InvokeADSPCompletionUPP(DSPPBPtr thePBPtr, ADSPCompletionUPP userUPP) = 0x4E91;
  275.     #else
  276.         #define InvokeADSPCompletionUPP(thePBPtr, userUPP)                 CALL_ONE_PARAMETER_UPP((userUPP), uppADSPCompletionProcInfo, (thePBPtr))
  277.     #endif
  278. #endif
  279. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  280. #define NewADSPConnectionEventProc(userRoutine)                 NewADSPConnectionEventUPP(userRoutine)
  281. #define NewADSPCompletionProc(userRoutine)                         NewADSPCompletionUPP(userRoutine)
  282. #define CallADSPConnectionEventProc(userRoutine, sourceCCB)        InvokeADSPConnectionEventUPP(sourceCCB, userRoutine)
  283. #define CallADSPCompletionProc(userRoutine, thePBPtr)            InvokeADSPCompletionUPP(thePBPtr, userRoutine)
  284.  
  285.  
  286. #if PRAGMA_STRUCT_ALIGN
  287.     #pragma options align=reset
  288. #elif PRAGMA_STRUCT_PACKPUSH
  289.     #pragma pack(pop)
  290. #elif PRAGMA_STRUCT_PACK
  291.     #pragma pack()
  292. #endif
  293.  
  294. #ifdef PRAGMA_IMPORT_OFF
  295. #pragma import off
  296. #elif PRAGMA_IMPORT
  297. #pragma import reset
  298. #endif
  299.  
  300. #ifdef __cplusplus
  301. }
  302. #endif
  303.  
  304. #endif /* __ADSP__ */
  305.  
  306.